from typing import Tuple

from prettytable import PrettyTable

import utils.enum as enum

__all__ = [
    "get_table",  # ->  获取 PrettyTable 表格
]


def get_table(
        title: str,
        headers: Tuple[str, ...],
        text_align: str = enum.PrettyTableTextAlign.LEFT.value,
) -> PrettyTable:
    """
    获取 PrettyTable 表格

    :param title:       标题
    :param headers:     表头
    :param text_align:  文本对齐方式（默认左对齐）
    :return:            PrettyTable 表格
    """

    table: PrettyTable = PrettyTable()
    table.field_names = headers
    table.title = title

    for _ in headers:
        table.align[_] = text_align

    return table
